package com.fancy.picture.test;

import java.awt.Rectangle;

public class PointRectangle extends Rectangle {

	private static final long serialVersionUID = -2465363144347743255L;

	int x1, x2, y1, y2;

	public PointRectangle(int x1, int y1, int x2, int y2) {
		this.x1 = x = x1;
		this.x2 = x2;
		this.y1 = y = y1;
		this.y2 = y2;
		width = x2 - x1;
		height = y2 - y1;
		if (x2 < x1) {
			x = x2;
			width = x1 - x2;
		}
		if (y2 < y1) {
			y = y2;
			height = y1 - y2;
		}
	}

	public PointRectangle(Rectangle rectangle) {
		super(rectangle.x, rectangle.y, rectangle.width, rectangle.height);
		this.x1 = rectangle.x;
		this.y1 = rectangle.y;
		this.x2 = rectangle.x + rectangle.width;
		this.y2 = rectangle.y + rectangle.height;
	}

}
